#define _GNU_SOURCE
#include<pthread.h>
#include<stdio.h>
#include<unistd.h>

void *thread1_func1(void *arg)
{
    int i=0;
    while(i<5)
    {
            i++;
        printf("thread11111 is id: %d\n",gettid());
        sleep(1);
    }
    return NULL;
}
void *thread2_func2(void *arg)
{
    int i=0;
    while(i<10)
    {
            i++;
        printf("thread22222 is id: %d\n",gettid());
        sleep(1);
    }
    return NULL;
}
int main()
{
    //声明线程句柄
    pthread_t thread1,tread2;
    pthread_create(&thread1,NULL,thread1_func1,NULL);
    pthread_create(&tread2,NULL,thread2_func2,NULL);

    sleep(5);
    pthread_cancel(thread1);
    printf("thread1 is cancel\n");
    //等待子进程jieshu
    pthread_join(thread1,NULL);
    pthread_join(tread2,NULL);
    printf("main thread is over\n");


}